<template>
  <div>
<h1>过滤器</h1>
<p v-for="item in nameList" :key="item">{{item |upper }}</p>
<p v-for="item in moneys" :key="item">{{item | toFixed2}}</p>
  </div>
</template>

<script>
  export default {
  data() {
    return {
     nameList:['fsg','sdhd','shrjj','kkukk'],
     moneys:[11.23444,67.4335,4.5567688,78.8898,6.778]
    }
  },
  filters:{
    //首字母大写
    upper(data){
      //截取第一个并大写
      return data.substr(0,1).toUpperCase()+data.substr(1)
    },
    //截取两位数的数字
    toFixed2(data){
      return data.toFixed(2)

    },
  },
  created(){
    console.log(this);
  }
    
  }
</script>

<style lang="scss" scoped>

</style>